﻿@using System.Web.Mvc
@using Webdiyer.WebControls.Mvc
@using KXCXW.Web.CommonClass
@using kxcxw.Data.Common
@model PagedList<kxcxw.Data.Entities.Activity>
@{
    CommonRepositories comm = new CommonRepositories();
}
<script type="text/javascript">
    $(function () {
        $(".delete").click(function () {
            if (confirm("确定要删除这条记录么？")) {
                return true;
            }
            else {
                return false;
            }
        });
    }); 
</script>
<div id="dvOrders" class="product_list">
    @Html.ActionLink("按发布时间排序", "MyInfoList", new { sortOrder = ViewBag.DateSortParm })
    <table cellpadding="0" cellspacing="0" border="0">
        @foreach (var item in Model)
        {
            <tr>
                <td style="width: 10%;">
                    <a href="javascript:void(0)" class="pic">
                        <img alt="" src="@Url.Content("~/Content/upload/Activity/img_135_90/" + item.ImageName)" /></a>
                </td>
                <td style="width: 90%;">
                    <ul style="margin-bottom: 10px;">
                        <li style="margin-right: 20px;">
                            @if (item.ShopType == 1)
                            {
                                <a href="@item.ShopUrl" target="_blank" style="color:#333333;">@item.Title</a>
                            }
                            else
                            {
                                @Html.ActionLink(item.Title, "ProductDetails", "Home", new { id = item.ActivityId }, new { target = "_blank", style = "color:#333333;" })
                            }
                        </li>
                        <li style="margin-right: 20px;">
                            @if (item.Status == DataConstants.Normal)
                            {
                                DateTime TempDate = DateTime.Now.AddDays(-DataConstants.ExpirationDay);
                                if ((item.EndDate == null && item.CreateDate >= TempDate) || item.EndDate >= DateTime.Now)
                                {
                                <font color="green">(正常)</font>
                                }
                                else
                                {
                                <font color="#666666">(过期)</font>
                                }
                            }
                            else if (item.Status == DataConstants.pending)
                            {
                                <font color="red">(未通过)</font> 
                            }
                            else if (item.Status == DataConstants.Deleted)
                            {
                                <font color="red">(已删除)</font> 
                            }
                        </li>
                    </ul>
                    <ul>
                        <li>
                            @string.Format("{0:D}", DateTime.Parse(@Html.DisplayFor(modelItem => item.CreateDate).ToString()))</li>
                        @if (item.Status != DataConstants.Deleted)
                        {
                            <li>
                                @Html.ActionLink("修改", "Edit", new { id = item.ActivityId }, new { @class = "edit", target = "_blank" })
                                |
                                @Html.ActionLink("删除", "Delete", new { id = item.ActivityId, order = ViewBag.DateSortParm, searchString = Request.QueryString["searchString"] == null ? "" : Request.QueryString["searchString"].ToString(), page = Request.QueryString["page"] == null ? 1 : Convert.ToInt32(Request.QueryString["page"]) }, new { @class = "delete" })
                            </li>
                        }
                    </ul>
                </td>
            </tr>
        }
    </table>
    <div class="pager">
        @Html.AjaxPager(
                    Model,
                    new PagerOptions()
                    {
                        PageIndexParameterName = "page",
                        FirstPageText = "首页",
                        LastPageText = "尾页",
                        NextPageText = "后一页",
                        PrevPageText = "前一页"
                    },
                    new AjaxOptions
                    {
                        UpdateTargetId = "dvOrders",

                    })
    </div>
</div>
